home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
escplus.asm
< prev
next >
Wrap
Assembly Source File
|
1985-06-03
|
5KB
|
172 lines
name ESCPLUS
page 60,132
title 'ESCPLUS--send an escape sequence to LPT1'
;This program sends and escape code (ASCII 27)
;and up to two other characters to LPT1.
;The characters to be sent are given to this
;program from the command line. If no
;arguments are given, instructions are printed
;on the screen.
;Assemble this program with the IBM Assembler
;then link it, then run exe2bin and make it a
;com file (i.e. EXE2BIN ESCPLUS ESCPLUS.COM)
;ESCPLUS--Written by Harry Logan
;March 13, 1984. This program has been given
;to the world!
;Version 2.1 --> Last One!! (ha ha ha!)
cr equ 13 ;carrige return
lf equ 10 ;line feed
escape equ 27 ;escape (ASCII 027)
eom equ 24h ;end of message ($)
cseg segment para public 'CODE'
assume cs:cseg,ds:cseg,es:nothing,ss:nothing
org $+0100h ;make this a com file
start: jmp begin
;Set-up messages
msg1 db 'Escape character plus--> ',eom
msg2 db ' <--sent to LPT1:',cr,lf,eom
code1 db ?
code2 db ?
;error messages--#1 is no command line arguments
errmsg1 db 'This program sends an escape'
db ' character plus up to 2 other',cr,lf
db 'characters of your choice'
db ' (transmitted to this program via',cr,lf
db 'the command line) to LPT1:',cr,lf
db 'i.e. ESCPLUS char1 char2',cr,lf,eom
errmsg2 db 'Printer not responding',cr,lf
db 'Aborting',cr,lf,eom
;Copyright message (not used)
copyrte db 'Copyright 1984-Harry Logan',cr,lf
db 'All rights reserved--Version 2.1',cr,lf,eom
;end of messages
begin: ;let's start
push ds ;save ds for return to DOS
xor ax,ax ;clear a reg
push ax ;and save it
call getchar ;go process command line
;start the procedure
push bx ;let's make sure we have it
cmp bx,0 ;no command line?
je nocmmd ;print instuctions and exit
;check and make sure the printer is okay
mov dx,0 ;we want lpt1
mov ah,2 ;id for printer status
int 17h ;call DOS
cmp ah,144 ;is everything cool?
jne lpterr ;no, exit gracefully
mov dl,escape ;put ASCII 27 in dl
mov ah,5 ;id for DOS
int 21h ;call DOS to do the work
mov dl,code1 ;First character
mov ah,5 ;Make sure it's the same
int 21h ;call DOS and send it
cmp bx,1 ;another character?
je bye ;no, go say good-bye
mov dl,code2 ;otherwise get second character
mov ah,5 ;make sure again
int 21h ;Call DOS and send it
bye: ;successful--say good-bye
mov dx,offset msg1 ;point to first msg
mov ah,9 ;id number
int 21h ;call DOS
mov dl,code1 ;First code for verification
mov ah,2 ;id number (display character)
int 21h ;DOS!!!
pop bx ;get it back
cmp bx,1 ;is there 2 args?
je bye2 ;nope
mov dl,code2 ;2nd code for verification
mov ah,2 ;id number
int 21h ;DOS again
bye2: mov dx,offset msg2 ;end of message
mov ah,9 ;id number
int 21h ;DOS again
jmp exit ;done!
nocmmd: ;no command line
mov dx,offset errmsg1 ;point to 1st error message
mov ah,9 ;id number
int 21h ;call DOS
jmp exit ;done!
lpterr: ;printer error
pop bx ;get this off the stack
mov dx,offset errmsg2 ;point to 2nd error message
mov ah,9 ;id number
int 21h ;call DOS
exit: ;we're all done
ret ;far return to DOS
getchar proc near ;process command line
;returns code1, code2 (if there is)
;and puts 0, 1, or 2 in bx depending on number
;of command line arguments. (0 args jumps
;to nocmmd after return
mov si,80h ;point to the number of args
mov cl,[si] ;move it to a reg
cmp cl,0 ;no args?
je noargs ;oops--print some instructions
cmp cl,1 ;just a space?
je noargs ;yes, so no arguments
cmp cl,2 ;one arg?
je onearg ;go process it
jmp twoargs ;otherwise there must be two--ignore all others
noargs: ;no args, put 0 in bx
mov bx,0 ;put 0 in bx
ret ;and return
onearg: mov di,offset code1 ;create a space
arg1: inc si ;ignore leading blanks
mov al,[si] ;move it to a reg
cmp al,' ' ;check for space
je arg1 ;loop
mov [di],al ;copy it to code1
mov bx,1 ;tell caller only one arg
ret ;and return
twoargs: mov di,offset code1 ;create a space
arg2: inc si
mov al,[si] ;same as above^
cmp al,' ' ;check for space
je arg2 ;loop till we get a character
mov [di],al ;move it to code1
mov di,offset code2 ;point to second arg space
ttws: inc si ;ignore second space
mov al,[si] ;move it to a reg
cmp al,' ' ;another space?
je ttws ;go back and loop
mov [di],al ;put it in our space
mov bx,2 ;tell caller there's 2 args
ret ;and return
getchar endp
cseg ends
end start
caller there's 2 args
ret ;and return
getchar endp
cseg ends
end start